package com.sec.android.app.myfiles.fragment.settings;

import android.app.Fragment;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.sec.android.app.myfiles.R;
import com.sec.android.app.myfiles.activity.SettingsActivity;
import com.sec.android.app.myfiles.util.UiUtils;

public class AbsSettingsFragment extends Fragment {
    protected int mProcessId;
    protected SettingsActivity mActivity;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        UiUtils.setContentsArea(getActivity(), R.id.settings_layout_container,
                getResources().getConfiguration().screenWidthDp);
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        mActivity = (SettingsActivity)getActivity();
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        UiUtils.setContentsArea(getActivity(), R.id.settings_layout_container, newConfig.screenWidthDp);
        if (UiUtils.isDensityDpiChanged(newConfig, mActivity.getDensityDpi())) {
            UiUtils.replaceFragment(this);
        }
    }

    public void setProcessId(int processId) {
        mProcessId = processId;
    }
}
